﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Heaven.Texturing
{
    /// <summary>
    /// Represent an abstract class of texture layer
    /// </summary>
    public class Layer
    {
        #region Events

        /// <summary>
        /// Event occurs when a polygonal object has been changed
        /// </summary>
        public event EventHandler Changed;

        /// <summary>
        /// Raises Changed event
        /// </summary>
        protected void RaiseChangedEvent()
        {
            if (Changed != null) Changed(this, EventArgs.Empty);
        }

        #endregion

        #region Fields

        /// <summary>
        /// Raw data with texels
        /// </summary>
        protected byte[] data;

        /// <summary>
        /// Format of texels
        /// </summary>
        protected LayerFormat format;

        #endregion

        #region Properties

        /// <summary>
        /// Raw data with texels
        /// </summary>
        public byte[] Data
        {
            get { return data; } 
        }

        /// <summary>
        /// Format of texels
        /// </summary>
        public LayerFormat Format
        {
            get { return format; }
        }

        #endregion

        #region Initialization

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="data">Raw data with pixels</param>
        /// <param name="format">Format of the pixels</param>
        protected Layer(byte[] data, LayerFormat format)
        {
            this.data = data;
            this.format = format;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Notices that changes have been performaed
        /// </summary>
        public void Invalidate()
        {
            RaiseChangedEvent();
        }

        #endregion
    }
}
